/**
 * Copyright (C) 2010 DustedPixels.com
 */
package com.dustedpixels.cirt.model.base;

import com.dustedpixels.cirt.model.core.In;
import com.dustedpixels.cirt.model.core.Out;

/**
 * A circuit which takes "clock" as an input, and reports "enable" when clock
 * goes from false to true.
 * 
 * @author Michal Pociecha-Los (micapolos@gmail.com)
 */
public final class Trigger {
  @In public boolean clk;
  @Out public boolean enable;
  
  private boolean lastClk;
  
  public void update() {
    enable = clk && (clk ^ lastClk);
    lastClk = clk;
  }
}
